import React from 'react'
import store from '../../store/store'
import {getMovieAction} from '../../store/actions/movieAction' 
import { useDispatch,useSelector } from 'react-redux'

export default function Movie() {
  //新的方法！ useDispatch & useSelector
    const dispatch = useDispatch()
    const count = useSelector(state=>state.count.count)
    const movieList = useSelector(state=>state.movie.movieList)

    const getMovieHandle = ()=>{
        dispatch(getMovieAction())
    }
  return (
    <div>
        <h3>我是Movie组件,我收到的Count组件的值是:{count}</h3>
        <button onClick={getMovieHandle}>请求数据</button>
        <ul>
            {
                movieList.map(item=>{
                    return <li key={item.tvId}>{item.albumName}</li>
                })
            }
        </ul>
    </div>
  )
}
